package com.hollycrm.unicom.sheet.flowsupport;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * DoOperateContext
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
public final class DoOperateContext implements Serializable {

    private final static String REGION_KEY = "key.";
    private final static String REGION_CLASS = "class.";
    private final static String REGION_LIST = "list.";

    private Map inputAttributes = new HashMap();
    private Map outputAttributes = new HashMap();

    public void addInputAttr(String key, Object obj) {
        inputAttributes.put(REGION_KEY + key, obj);
    }

    public void addInputAttr(Object obj) {
        if (obj != null)
            inputAttributes.put(REGION_CLASS + obj.getClass().getName(), obj);
    }

    public void addInputListAttr(String key, List list) {
        if (list != null && !list.isEmpty())
            inputAttributes.put(REGION_LIST + key, list);
    }

    public Object getInputAttr(String key) {
        return inputAttributes.get(REGION_KEY + key);
    }

    public Object getInputAttr(Class clazz) {
        return inputAttributes.get(REGION_CLASS + clazz.getName());
    }

    public List getInputListAttr(String key) {
        return (List) inputAttributes.get(REGION_LIST + key);
    }

    public void addOutputAttr(String key, Object obj) {
        outputAttributes.put(REGION_KEY + key, obj);
    }

    public void addOutputAttr(Object obj) {
        if (obj != null)
            outputAttributes.put(REGION_CLASS + obj.getClass().getName(), obj);
    }

    public void addOutputListAttr(String key, List list) {
            if (list != null && !list.isEmpty())
                outputAttributes.put(REGION_LIST + key, list);
        }

    public Object getOutputAttr(String key) {
        return outputAttributes.get(REGION_KEY + key);
    }

    public Object getOutputAttr(Class clazz) {
        return outputAttributes.get(REGION_CLASS + clazz.getName());
    }

    public List getOutputListAttr(String key) {
        return (List) outputAttributes.get(REGION_LIST + key);
    }

}
